<?php


namespace App\Admin\Forms\Config;


use App\Models\Config\SystemData;
use Dcat\Admin\Form\NestedForm;
use Dcat\Admin\Form\Row;
use Dcat\Admin\Layout\Column;
use Dcat\Admin\Widgets\Form;
use Illuminate\Support\Arr;

class SocialConfig extends JsonConfigForm
{

    public static function label() :array
    {
        return [
            "name"=>"名称",
            "url"=>"链接",
            "icon"=>"图标",
            "qrcode"=>"二维码",
        ];
    }

    public function configKey(): string
    {
        return SystemData::DATA_SOCIAL_INFO;
    }

    public function configName() :string
    {
        return "社交账号";
    }


    public function form()
    {
        $label = static::label();
        $this->column(4,function () use($label){
            $this->text('social.0.name',Arr::get($label,"name"))->required();
            $this->url('social.0.url',Arr::get($label,"url"))->required();
            $this->image('social.0.icon',Arr::get($label,"icon"))->autoUpload()->disk("public");
            $this->image('social.0.qrcode',Arr::get($label,"qrcode"))->autoUpload()->disk("public");
        });
        $this->column(4,function () use($label){
            $this->text('social.1.name',Arr::get($label,"name"))->required();
            $this->url('social.1.url',Arr::get($label,"url"))->required();
            $this->image('social.1.icon',Arr::get($label,"icon"))->autoUpload()->disk("public");
            $this->image('social.1.qrcode',Arr::get($label,"qrcode"))->autoUpload()->disk("public");
        });
        $this->column(4,function () use($label){
            $this->text('social.2.name',Arr::get($label,"name"))->required();
            $this->url('social.2.url',Arr::get($label,"url"))->required();
            $this->image('social.2.icon',Arr::get($label,"icon"))->autoUpload()->disk("public");
            $this->image('social.2.qrcode',Arr::get($label,"qrcode"))->autoUpload()->disk("public");
        });
    }
}
